pspmoduleinfo.h

Go to the documentation of this file.
00001 /*
00002  * PSP Software Development Kit - http://www.pspdev.org
00003  * -----------------------------------------------------------------------
00004  * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
00005  *
00006  * pspmoduleinfo.h - Definitions for the .rodata.sceModuleInfo ELF section.
00007  *
00008  * Copyright (c) 2005 Marcus R. Brown <mrbrown@ocgnet.org>
00009  * Copyright (c) 2005 James Forshaw <tyranid@gmail.com>
00010  * Copyright (c) 2005 John Kelley <ps2dev@kelley.ca>
00011  *
00012  * $Id: pspmoduleinfo.h 1721 2006-01-19 22:19:08Z tyranid $
00013  */
00014 #ifndef PSPMODULEINFO_H
00015 #define PSPMODULEINFO_H
00016 
00017 /* Note: Some of the structures and definitions in this file were extrapolated from
00018    symbolic debugging information found in the Japanese version of Puzzle Bobble. */
00019 
00020 /* Module info structure.  Used to declare a module (library or executable).  This structure
00021    is required in all PSP executables. */
00022 typedef struct _scemoduleinfo {
00023         unsigned short          modattribute;
00024         unsigned char           modversion[2];
00025         char                    modname[27];
00026         char                    terminal;
00027         void *                  gp_value;
00028         void *                  ent_top;
00029         void *                  ent_end;
00030         void *                  stub_top;
00031         void *                  stub_end;
00032 } _sceModuleInfo;
00033 
00034 typedef const _sceModuleInfo SceModuleInfo;
00035 
00036 extern char _gp[];
00037 
00038 enum PspModuleInfoAttr
00039 {
00040         PSP_MODULE_USER   = 0,
00041         PSP_MODULE_KERNEL = 0x1000,
00042 };
00043 
00044 #ifdef __cplusplus
00045 
00046 /* Declare a module.  This must be specified in the source of a library or executable. */
00047 #define PSP_MODULE_INFO(name, attributes, major_version, minor_version) \
00048         __asm__ (                                                       \
00049         "    .set push\n"                                               \
00050         "    .section .lib.ent.top, \"a\", @progbits\n"                 \
00051         "    .align 2\n"                                                \
00052         "    .word 0\n"                                                 \
00053         "__lib_ent_top:\n"                                              \
00054         "    .section .lib.ent.btm, \"a\", @progbits\n"                 \
00055         "    .align 2\n"                                                \
00056         "__lib_ent_bottom:\n"                                           \
00057         "    .word 0\n"                                                 \
00058         "    .section .lib.stub.top, \"a\", @progbits\n"                \
00059         "    .align 2\n"                                                \
00060         "    .word 0\n"                                                 \
00061         "__lib_stub_top:\n"                                             \
00062         "    .section .lib.stub.btm, \"a\", @progbits\n"                \
00063         "    .align 2\n"                                                \
00064         "__lib_stub_bottom:\n"                                          \
00065         "    .word 0\n"                                                 \
00066         "    .set pop\n"                                                \
00067         );                                                              \
00068         extern char __lib_ent_top[], __lib_ent_bottom[];                \
00069         extern char __lib_stub_top[], __lib_stub_bottom[];              \
00070         extern SceModuleInfo module_info                                \
00071                 __attribute__((section(".rodata.sceModuleInfo"),        \
00072                                aligned(16), unused)) = {                \
00073           attributes, { minor_version, major_version }, #name, 0, _gp,  \
00074           __lib_ent_top, __lib_ent_bottom,                              \
00075           __lib_stub_top, __lib_stub_bottom                             \
00076         }
00077 #else
00078 /* Declare a module.  This must be specified in the source of a library or executable. */
00079 #define PSP_MODULE_INFO(name, attributes, major_version, minor_version) \
00080         __asm__ (                                                       \
00081         "    .set push\n"                                               \
00082         "    .section .lib.ent.top, \"a\", @progbits\n"                 \
00083         "    .align 2\n"                                                \
00084         "    .word 0\n"                                                 \
00085         "__lib_ent_top:\n"                                              \
00086         "    .section .lib.ent.btm, \"a\", @progbits\n"                 \
00087         "    .align 2\n"                                                \
00088         "__lib_ent_bottom:\n"                                           \
00089         "    .word 0\n"                                                 \
00090         "    .section .lib.stub.top, \"a\", @progbits\n"                \
00091         "    .align 2\n"                                                \
00092         "    .word 0\n"                                                 \
00093         "__lib_stub_top:\n"                                             \
00094         "    .section .lib.stub.btm, \"a\", @progbits\n"                \
00095         "    .align 2\n"                                                \
00096         "__lib_stub_bottom:\n"                                          \
00097         "    .word 0\n"                                                 \
00098         "    .set pop\n"                                                \
00099         );                                                              \
00100         extern char __lib_ent_top[], __lib_ent_bottom[];                \
00101         extern char __lib_stub_top[], __lib_stub_bottom[];              \
00102         SceModuleInfo module_info                                       \
00103                 __attribute__((section(".rodata.sceModuleInfo"),        \
00104                                aligned(16), unused)) = {                \
00105           attributes, { minor_version, major_version }, name, 0, _gp,  \
00106           __lib_ent_top, __lib_ent_bottom,                              \
00107           __lib_stub_top, __lib_stub_bottom                             \
00108         }
00109 #endif
00110 
00111 /* Define the main thread's initial priority. */
00112 #define PSP_MAIN_THREAD_PRIORITY(priority) \
00113         unsigned int sce_newlib_priority = (priority)
00114 /* Define the main thread's stack size (in KB). */
00115 #define PSP_MAIN_THREAD_STACK_SIZE_KB(size_kb) \
00116         unsigned int sce_newlib_stack_kb_size = (size_kb)
00117 /* Define the main thread's attributes. */
00118 #define PSP_MAIN_THREAD_ATTR(attr) \
00119         unsigned int sce_newlib_attribute = (attr)
00120 #define PSP_MAIN_THREAD_ATTRIBUTE PSP_MAIN_THREAD_ATTR
00121 
00122 /* Define all main thread parameters. */
00123 #define PSP_MAIN_THREAD_PARAMS(priority, size_kb, attribute) \
00124         PSP_MAIN_THREAD_PRIORITY(priority); \
00125         PSP_MAIN_THREAD_STACK_SIZE_KB(size_kb); \
00126         PSP_MAIN_THREAD_ATTR(attribute)
00127 
00128 /* If declared, the runtime code won't create a main thread for the program. */
00129 #define PSP_NO_CREATE_MAIN_THREAD() \
00130         int sce_newlib_nocreate_thread_in_start = 1
00131 
00132 /* Declare the size of the heap (in KB) that the program wants to allocate from. */
00133 #define PSP_HEAP_SIZE_KB(size_kb) \
00134         unsigned int sce_newlib_heap_kb_size = (size_kb)
00135 
00136 /* Declare the name of the main thread */
00137 #define PSP_MAIN_THREAD_NAME(s) const char* sce_newlib_main_thread_name = (s)
00138 
00139 #endif /* PSPMODULEINFO_H */

Generated on Tue Nov 21 11:46:04 2006 for pspsdk-1.0+beta2 by  doxygen 1.4.6